home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the 3D Game Programming Gurus / gurus.iso / DirectX / dx9sdkcp.exe / SDK (C++) / Samples / Media / SeaFloor2.vsh < prev    next >
Encoding:
Text File  |  2002-11-12  |  2.1 KB  |  69 lines

  1. vs.1.1
  2. ;------------------------------------------------------------------------------
  3. ; Constants specified by the app
  4. ;    c0      = ( 0, 0, 0, 0 )
  5. ;    c1      = ( 1, 0.5, 2, 4 )
  6. ;    c4-c7   = world-view-projection matrix
  7. ;    c8-c11  = world-view matrix
  8. ;    c12-c15 = view matrix
  9. ;    c20     = light direction
  10. ;    c21     = material diffuse color * light diffuse color
  11. ;    c22     = material ambient color
  12. ;    c28     = projection matrix
  13. ;
  14. ; Vertex components (as specified in the vertex DECL)
  15. ;    v0    = Position
  16. ;    v3    = Normal
  17. ;    v6    = Texcoords
  18. ;------------------------------------------------------------------------------
  19.  
  20. dcl_position0 v0
  21. dcl_normal0   v3
  22. dcl_texcoord0 v6
  23.  
  24. ;------------------------------------------------------------------------------
  25. ; Vertex transformation
  26. ;------------------------------------------------------------------------------
  27.  
  28. ; Transform to view space (world matrix is identity)
  29. m4x4 r9, v0, c12
  30.  
  31. ; Transform to projection space
  32. m4x4 r10, r9, c28
  33.  
  34. ; Store output position
  35. mov oPos, r10
  36.  
  37.  
  38. ;------------------------------------------------------------------------------
  39. ; Lighting calculation
  40. ;------------------------------------------------------------------------------
  41.  
  42. dp3 r1.x, v3, c20    ; r1 = normal dot light
  43. max r1, r1.x, c0.x     ; if dot < 0 then dot = 0
  44. mul r0, r1.x, c21    ; Multiply with diffuse
  45. add r0, r0, c22      ; Add in ambient
  46. min oD0, r0, c1.x    ; clamp if > 1
  47.  
  48.  
  49. ;------------------------------------------------------------------------------
  50. ; Texture coordinates
  51. ;------------------------------------------------------------------------------
  52.  
  53. ; Gen tex coords from vertex xz position
  54. mul r0.xy, c24.x, r9.xz
  55. add oT0.xy, r0.xy, c24.zw
  56.  
  57. ;------------------------------------------------------------------------------
  58. ; Fog calculation
  59. ;------------------------------------------------------------------------------
  60.  
  61. ; compute fog factor f = (fog_end - dist)*(1/(fog_end-fog_start))
  62. add r0.x, -r9.z, c23.y
  63. mul r0.x, r0.x, c23.z
  64. max r0.x, r0.x, c0.x       ; clamp fog to > 0.0
  65. min oFog, r0.x, c1.x     ; clamp fog to < 1.0
  66.  
  67.  
  68.  
  69.